Skip to content

refactor: make ConnectionPlan.connect_args read-only#25

Merged
lesnik512 merged 1 commit into
mainfrom
refactor/connect-args-readonly
Jun 27, 2026
Merged

refactor: make ConnectionPlan.connect_args read-only#25
lesnik512 merged 1 commit into
mainfrom
refactor/connect-args-readonly

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Tiny hardening folded in from the connection-plan-split (#24) final review. No behavior change, no release intended.

ConnectionPlan.connect_args is annotated Mapping[str, Any] (read-only intent) but stored the live dict. This wraps it in types.MappingProxyType(...) so the annotation is literally true — the seam can't be mutated through.

Changes

  • db_retry/connections.pyimport types; connect_args=types.MappingProxyType(connect_args) when building the plan. _connect's **plan.connect_args works unchanged on a MappingProxyType.
  • tests/test_connection_factory.py — test that plan.connect_args rejects mutation (TypeError).
  • Lightweight-lane bundle planning/changes/2026-06-27.01-connect-args-readonly/.

Verification

  • TDD: mutation succeeded on the plain dict (RED) → raises TypeError after the wrap (GREEN).
  • just test28 passed, 100% coverage (loop tests confirm ** unpacking still works).
  • just lint-ci → clean; just check-planningplanning: OK.

🤖 Generated with Claude Code

…Type

Wraps the popped connect_args dict in types.MappingProxyType so the
Mapping annotation is literally read-only at runtime. No behavior change
(the dict was never mutated post-construction); _connect's ** unpacking
works unchanged. Lightweight-lane change bundle included.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit 4d045e0 into main Jun 27, 2026
2 checks passed
@lesnik512 lesnik512 deleted the refactor/connect-args-readonly branch June 27, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant